const router = new require("@koa/router")({ prefix: "/user" });
const { auth } = require("../middleware/auth")

const {
    register,
    login,
    get_user_friends,
    update_line_status,
    add_friend,
    getUserIdByQq
} = require("../controller/user_controller");

const {
  register_validator,
  login_validator,
  user_friends_validator,
  update_line_status_validator,
  add_friend_validator,
  get_userId_by_qqAccount_validator
} = require("../validate/user_validate");

/**
 * 用户注册
 */
router.post("/register", register_validator,register);

/**
 * 用户登录
 */
router.post("/login", login_validator,login);

/**
 * 获取用户好友列表
 */
router.get("/get_user_friends",auth, user_friends_validator,get_user_friends);

/**
 * 修改用户在线状态
 */
 router.put("/update_line_status",auth,update_line_status_validator ,update_line_status);

/**
 * 添加好友
 */
 router.put("/add_friend",auth,add_friend_validator ,add_friend);


/**
 * 根据QQ号获取到一个用户ID
 */
 router.get("/get_userId_by_qq",get_userId_by_qqAccount_validator ,getUserIdByQq);

/**
 * 认证登录态
 */
router.post("/auth",auth);

module.exports = router;
